import java.util.concurrent.CountDownLatch;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-04-15
 * Time: 9:42
 */
public class Demo5 {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch count=new CountDownLatch(10);
        for (int i = 0; i <10 ; i++) {
            int id=i;
            Thread t=new Thread(()->{
                System.out.println("线程启动: "+id);
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("线程结束:"+id);
                count.countDown();

            });
            t.start();
        }
        count.await();
        System.out.println("所有线程结束");

    }
}
